home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / attribs / cfgitem.h < prev    next >
C/C++ Source or Header  |  2001-10-08  |  3KB  |  108 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29. #ifndef _CFGITEM_H
  30. #define _CFGITEM_H
  31.  
  32. #include "../common/dispatch.h"
  33.  
  34. class Dependent;
  35.  
  36. // abstract base class presented to the world
  37. class NOVTABLE CfgItem : public Dispatchable {
  38. public:
  39.   const char *getName();
  40.   int getNumAttributes();
  41.   const char *enumAttribute(int n);
  42.  
  43.   // so people can watch you for changes
  44.   Dependent *getDependencyPtr();
  45.  
  46.   // if you have child cfgitems, list them here
  47.   int getNumChildren();
  48.   CfgItem *enumChild(int n);
  49.   void shutdown();
  50.  
  51.   virtual int getAttributeType(const char *name)=0;
  52.   virtual int getDataLen(const char *name)=0;
  53.   virtual int getData(const char *name, void *data, int data_len)=0;
  54.   virtual int setData(const char *name, void *data, int data_len)=0;
  55.  
  56.   enum {
  57.     GETNAME=100,
  58.     GETNUMATTRIBUTES=200,
  59.     ENUMATTRIBUTE=210,
  60.     GETDEPENDENCYPTR=300,
  61.     GETNUMCHILDREN=400,
  62.     ENUMCHILD=410,
  63.     SHUTDOWN=500,
  64.   };
  65. };
  66.  
  67. inline const char *CfgItem::getName() {
  68.   return _call(GETNAME, "");
  69. }
  70.  
  71. inline int CfgItem::getNumAttributes() {
  72.   return _call(GETNUMATTRIBUTES, 0);
  73. }
  74.  
  75. inline const char *CfgItem::enumAttribute(int n) {
  76.   return _call(ENUMATTRIBUTE, (const char*)NULL, n);
  77. }
  78.  
  79. inline Dependent *CfgItem::getDependencyPtr() {
  80.   return _call(GETDEPENDENCYPTR, (Dependent*)NULL);
  81. }
  82.  
  83. inline int CfgItem::getNumChildren() {
  84.   return _call(GETNUMCHILDREN, 0);
  85. }
  86.  
  87. inline CfgItem *CfgItem::enumChild(int n) {
  88.   return _call(ENUMCHILD, (CfgItem*)NULL, n);
  89. }
  90.  
  91. inline void CfgItem::shutdown() {
  92.   _voidcall(SHUTDOWN);
  93. }
  94.  
  95. inline int _intVal(CfgItem *cfgitem, const char *name, int def_val=0) {
  96.   int ret;
  97.   if (!cfgitem->getData(name, &ret, sizeof(ret))) return def_val;
  98.   return ret;
  99. }
  100. #define _int_getValue _intVal
  101.  
  102. inline void _int_setValue(CfgItem *cfgitem, const char *name, int val) {
  103.   cfgitem->setData(name, &val, sizeof(int));
  104. }
  105. // CfgItemI is in cfgitemi.h if you need it
  106.  
  107. #endif
  108.